package cc.vv.baselibrary.server;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;


import cc.vv.baselibrary.view.columnchart.bean.ShowPopwinDataObj;


/**
 * 提醒功能相关数据逻辑处理类
 * Created by sun.li on 2017/7/11.
 */

public class HealthRecordPopupwindowServer {

    private static HealthRecordPopupwindowServer sInstance;

    /**
     * 实例化对象
     */
    public static HealthRecordPopupwindowServer getInstance() {
        if (sInstance == null) {
            synchronized (HealthRecordPopupwindowServer.class) {
                if (null == sInstance) {
                    sInstance = new HealthRecordPopupwindowServer();
                }
            }
        }
        return sInstance;
    }

    /**
     * 设置弹窗显示数据
     *
     * @param tv_top            顶部显示控件
     * @param tv_bottom         底部显示控件
     * @param showPopwinDataObj 显示数据源
     * @param isShowTopText     是否显示topText
     */
    public void setHealthRecordData(TextView tv_top, TextView tv_bottom, ShowPopwinDataObj showPopwinDataObj, boolean isShowTopText) {
        String topText = "";
        String bottomText = "";
        switch (showPopwinDataObj.getCode()) {
            //心率
            case "LRTZ_JKZB_XL":
                topText = showPopwinDataObj.getValueData() + "次/分";
                break;
            //体重   LRTZ_JKZB_TZ
            case "LRTZ_JKZB_TZ":
                topText = showPopwinDataObj.getValueData() + "公斤";
                break;
            //步数   LRTZ_JKZB_STEP
            case "LRTZ_JKZB_STEP":
                topText = showPopwinDataObj.getValueData() + "步";
                break;
            //体温   LRTZ_JKZB_TW
            case "LRTZ_JKZB_TW":
                topText = showPopwinDataObj.getValueData() + "℃";
                break;
            //运动记录 LRTZ_YSRL_YDJL
            case "LRTZ_YSRL_YDJL":
                topText = "总消耗";
                bottomText = showPopwinDataObj.getValueData() + "kcal";
                break;
            //睡眠   LRTZ_RCXX_SMSJ
            case "LRTZ_RCXX_SMSJ":
                topText = "睡眠总时长";
                bottomText = showPopwinDataObj.getSleepStrHour();
                break;
            //血压   LRTZ_JKZB_XY
            case "LRTZ_JKZB_XY":
                topText = "收缩压" + showPopwinDataObj.getValueData();
                bottomText = "舒张压" + showPopwinDataObj.getValueData_2();
                break;
            //饮食记录 LRTZ_YSRL
            case "LRTZ_YSRL":
                topText = "总摄入";
                bottomText = showPopwinDataObj.getValueData() + "kcal";
                break;
            //血糖   LRTZ_JKZB_XT
            case "LRTZ_JKZB_XT":
                topText = isShowTopText ? "平均" : "";
                bottomText = showPopwinDataObj.getValueData() + "mmol/L";
                break;
        }

        if (!TextUtils.isEmpty(topText)) {
            tv_top.setVisibility(View.VISIBLE);
            tv_top.setText(topText);
        } else {
            tv_top.setVisibility(View.GONE);
        }
        if (!TextUtils.isEmpty(bottomText)) {
            tv_bottom.setVisibility(View.VISIBLE);
            tv_bottom.setText(bottomText);
        } else {
            tv_bottom.setVisibility(View.GONE);
        }
    }
}
